package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/09/10 22:52
 **/
public class Day8_5_Num238_ProductExceptSelf {
    class Solution {
        public int[] productExceptSelf(int[] nums) {
            int[] res = new int[nums.length];
            int product = 1;
            for(int i = 0; i < nums.length; ++i){
                res[i] = product;
                product *= nums[i];
            }
            product = 1;
            for(int i = nums.length-1; i >= 0; --i){
                res[i] *= product;
                product *= nums[i];
            }
            return res;
        }
    }
}